//
//  FDNavigationController.m
//  FastDoctor
//
//  Created by MyMacbookPro on 16/5/3.
//  Copyright © 2016年 MyMacbookPro. All rights reserved.
//

#import "FDNavigationController.h"

@interface FDNavigationController () <UIGestureRecognizerDelegate>

@end

@implementation FDNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationBar.barTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"nav"]];
    
    self.interactivePopGestureRecognizer.enabled = NO;
    
    id target = self.interactivePopGestureRecognizer.delegate;
    // 只能使用通过String获取selector的方式访问SEL
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:NSSelectorFromString(@"handleNavigationTransition:")];
    // 不能使用下面的方法，不能识别selector，而且还会默认禁用导航控制器的返回功能
//    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
    pan.delegate = self;
    [self.view addGestureRecognizer:pan];
    
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    return self.viewControllers.count > 2;
}

@end
